package com.yfree.views;

import android.content.Context;
import android.util.AttributeSet;

import com.yfree.libs.pulltorefresh.PullToRefreshGridView;

import java.text.SimpleDateFormat;
import java.util.Date;

public class YPullToRefreshGridView extends PullToRefreshGridView {
    public YPullToRefreshGridView(Context context) {
        super(context);
        changeStyle();
    }

    public YPullToRefreshGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
        changeStyle();
    }

    public YPullToRefreshGridView(Context context, Mode mode) {
        super(context, mode);
        changeStyle();
    }

    public YPullToRefreshGridView(Context context, Mode mode, AnimationStyle style) {
        super(context, mode, style);
        changeStyle();
    }

    private void changeStyle() {
        setMode(Mode.PULL_FROM_START);
        setPullLabel("继续下拉刷新...", Mode.PULL_FROM_START);
        setReleaseLabel("放开开始刷新...", Mode.PULL_FROM_START);
        setRefreshingLabel("拼命刷新中...", Mode.PULL_FROM_START);
        setPullLabel("上拉加载更多...", Mode.PULL_FROM_END);
        setReleaseLabel("放开以加载更多...", Mode.PULL_FROM_END);
        setRefreshingLabel("拼命加载中...", Mode.PULL_FROM_END);
    }

    @Override
    protected void onRefreshing(boolean doScroll) {
        super.onRefreshing(doScroll);
        getLoadingLayoutProxy(true, false).setLastUpdatedLabel("最后更新：" + new SimpleDateFormat("MM月dd日 HH:mm").format(new Date()));
    }
}
